package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.SoulPaperQuestion;
import com.tanhua.dubbo.api.SoulPaperQuestionApi;
import com.tanhua.dubbo.mapper.SoulPaperQuestionMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class SoulPaperQuestionAplImpl implements SoulPaperQuestionApi {

	@Autowired
	private SoulPaperQuestionMapper soulPaperQuestionMapper;

	/**
	 * 根据问卷id查询中间表中对应级别的所有试题从而拿到试题id
	 */
	@Override
	public List<SoulPaperQuestion> findQuestionList(Long id) {
		QueryWrapper<SoulPaperQuestion> queryWrapper = new QueryWrapper();
		queryWrapper.eq("paper_id",id);
		return soulPaperQuestionMapper.selectList(queryWrapper);
	}

	/**
	 * 通过试题id查询中间表,从而获取当前提交的是哪套问卷
	 */
	@Override
	public SoulPaperQuestion findOneByQuestionId(Long questionId) {
		return soulPaperQuestionMapper.selectById(questionId);
	}
}
